
/**
 *  \file storage_internal.h
 *
 */

/*
 *  Copyright (C) 2013. Mindtree Ltd.
 *  All rights reserved.
 */

#ifndef _H_STORAGE_INTERNAL_
#define _H_STORAGE_INTERNAL_

/* --------------------------------------------- Header File Inclusion */
#include "storage.h"
#include "BT_storage.h"
#include "BT_storage_pl.h"

/* --------------------------------------------- Global Definitions */
#define STORAGE_ID_INVALID                       0xFF

/* --------------------------------------------- Structures/Data Types */
/* Storage Array */
typedef struct _STORAGE_ARRAY
{
#ifdef HAVE_STORAGE_ID_OFFSET
    /* DB Module ID */
    UCHAR db_id;
#endif /* HAVE_STORAGE_ID_OFFSET */

    /* DB Module Callback */
    STORAGE_CB db_cb;

} STORAGE_ARRAY;

/* --------------------------------------------- Macros */
/* Debug Macros */
#ifndef STORAGE_NO_DEBUG
#define STR_ERR(...)            BT_debug_error(BT_MODULE_ID_STORAGE, __VA_ARGS__)
#else /* STORAGE_NO_DEBUG */
#define STR_ERR                 BT_debug_null
#endif /* STORAGE_NO_DEBUG */

#ifdef STORAGE_DEBUG
#define STR_TRC(...)            BT_debug_trace(BT_MODULE_ID_STORAGE, __VA_ARGS__)
#define STR_INF(...)            BT_debug_info(BT_MODULE_ID_STORAGE, __VA_ARGS__)
#else /* STORAGE_DEBUG */
#define STR_TRC                 BT_debug_null
#define STR_INF                 BT_debug_null
#endif /* STORAGE_DEBUG */


/** To Lock Storage global mutex */
#define storage_lock()          BT_MUTEX_LOCK(storage_mutex, STORAGE)

/** To Unlock Storage global mutex */
#define storage_unlock()        BT_MUTEX_UNLOCK(storage_mutex, STORAGE)

/** To Lock Storage global mutex */
#define storage_lock_void()     BT_MUTEX_LOCK_VOID(storage_mutex, STORAGE)

/** To Unlock Storage global mutex */
#define storage_unlock_void()   BT_MUTEX_UNLOCK_VOID(storage_mutex, STORAGE)


/* --------------------------------------------- Internal Functions */

#endif /* _H_STORAGE_INTERNAL_ */
